<template>
	<div class="">
		<!-- //费率修改 -->
		<van-nav-bar left-text="修改费率" left-arrow @click-left="onClickLeft" />
		<div class="flex flex-space" style="margin: 24px 15px 0px;flex-wrap: wrap;">
			<div class=""
				style="width: 48%;padding: 25px 0px;text-align: center; background: #FFFFFF;border-radius: 5px;margin-bottom: 15px; "
				v-for="(item,index) in PackageList" :key="index" @click="showPopup(item)">
				<div class="" style="font-weight: bold;font-size: 22px;color: #0580FF;font-family: auto">
					{{item.packageSaleTaxPrice}}
				</div>
				<div class=" " style="font-weight: 500;font-size: 13px;color: #BBBBBB;font-family: auto">
					{{item.packageName}}
				</div>
			</div>
		</div>
		<van-popup v-model="show" round>
			<div class="" style=" width: 300px;height: 280px; ">
				<div class="popup_tuik"
					style="font-size: 16px; padding: 17px 0px;text-align: center;font-weight: bold;font-family: auto;color: #FFFFFF;">
					文件复印费率
				</div>
				<div id=""
					style="font-size: 19px;font-weight: bolder; font-family: auto;margin: 30px 0px;text-align: center;">
					生活照费率修改
				</div>
				<div class="flex-c" style="">
					<input type="number" v-model="ratetext" style="text-align: center;padding: 5px;border: 0px;" placeholder="请输入修改金额" />
				</div>
				<div class="flex-c"
					style="width: 250px;height: 9px;margin: auto; border: 1px solid #E8E8E8;border-top: 0px;">
				</div>
				<div class="flex-c" style="margin: 20px 0px 8px;" @click="openpopup">
					<div class=""
						style="width: 250px;height: 34px;padding: 9px 107px;font-size: 16px;color: #FFFFFF;font-weight: 500;font-family: auto;background: #0580FF;border-radius: 5px; ">
						确定
					</div>
				</div>
				<div class="flex-c" style="margin-bottom:20px;" @click="closepopup">
					<div class=""
						style="width: 250px;height: 34px;padding: 9px 107px;font-size: 16px;color: #BBBBBB;font-weight: 500;font-family: auto; border-radius: 5px; ">
						取消
					</div>
				</div>
			</div>
		</van-popup> 
	</div>
</template>
<script>
	import {
		GetPackageList
	} from '@/api/setting/GetPackageList.js'
	import {
		NewAdjustsOrder
	} from '@/api/setting/NewAdjustsOrder.js'
	export default {
		data() {
			return {
				PackageList: [],
				terminalId: '', //父页面的参数
				show: false,
				ratetext: '', //弹窗搜索内容input
				packageSaleTaxPrice: '',
				packageId: ''
			}
		},
		created() {
			this.GetPackage();
		},
		methods: {
			// 关闭弹出框
			closepopup() {
				this.ratetext = '';
				this.show = false;
			},
			// 保存弹出框内容
			openpopup() {
				NewAdjustsOrder({
					"postdata": [{
							"field": "packageId",
							"value": this.packageId
						},
						{
							"field": "terminalId",
							"value": this.terminalId
						},
						{
							"field": "packageSaleTaxPrice",
							"value": this.packageSaleTaxPrice + ''
						},
						{
							"field": "itemNewPrice",
							"value": this.ratetext
						}
					]
				}).then(res => {
					if (res.success) {
						this.GetPackage()
						this.show = false;
						this.ratetext = '';
					}
					console.log(res, '修改价格')
				})
			},
			showPopup(item) {
				console.log(item, 'ewrf')
				this.packageSaleTaxPrice = item.packageSaleTaxPrice;
				this.packageId = item.packageId;
				this.show = true;
			},
			GetPackage() {
				console.log(this.$route.query, 'this.$route.query');
				this.terminalId = this.$route.query.terminalId;
				GetPackageList().then(res => {
					console.log(res, '费率修改')
					this.PackageList = res.data;
				})
			},
			onClickLeft() {
				// this.$router.go(-1)
				this.$router.push({
					path: '/setting',
					query: {
						setting: true,
					}
				})
			},

			// modifyRateselect(item) {
			// modifyRateselect({
			// 	"postdata": [{
			// 			"field": "packageId",
			// 			"value": item.packageId
			// 		},
			// 		{
			// 			"field": "terminalId",
			// 			"value": "10000006"
			// 		},
			// 		{
			// 			"field": "packageSaleTaxPrice",
			// 			"value": item.packageSaleTaxPrice
			// 		},
			// 		{
			// 			"field": "itemNewPrice",
			// 			"value": "2.1"
			// 		}

			// 	]
			// }).then(res => {
			// 	console.log(res, '修改价格')
			// })
			// }
		}
	}
</script>
<style>
	.rate div:nth-child(even) {
		margin-right: 2% !important;
	}
	.popup_tuik {
		background: url(../../../assets/newrefund/bg@2x.png) no-repeat;
		background-size: 100%;
	}
	
</style>
